/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servidormeteorologico;

import java.io.*;
import java.net.*;

/**
 *
 * @author dayana
 */
public class Cliente {

    public static void main(String[] args) throws IOException {

        Socket kkSocket = null;
        PrintWriter out = null;
        BufferedReader in = null;
        boolean opc = true;

        try {
            kkSocket = new Socket("172.16.210.24", 16000);
            out = new PrintWriter(kkSocket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
        } catch (UnknownHostException e) {
            System.err.println("Don't know about host: 172.16.210.24.");
            System.exit(1);
        } catch (IOException e) {
            System.err.println("Couldn't get I/O for the connection to: 172.16.210.24.");
            System.exit(1);
        }

        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        String fromServer;
        String fromUser;

        while (opc) {
            System.out.print("\nClient: ");
            fromUser = stdIn.readLine();
            if (fromUser != null) {
                out.println(fromUser);
                if (fromUser.equals("Saliendo del programa.")) {
                    break;
                }

                fromServer = in.readLine();
                 System.out.print("\nServidor: " + fromServer);

            }
        }
        System.out.println("Cerrando socket..");
        out.close();
        in.close();
        stdIn.close();
        kkSocket.close();

    }
}
